<template>
  <navbar title="授权结果" :isBack="true"></navbar>
  <loading v-if="!status"></loading>
  <view class="page flex-direction-column" :style="{ height: tools.clientTopHight() }" v-else>
    <img v-if="status == 0" src="/pagesA/static/image/40.png" alt="" />
    <img v-else src="/pagesA/static/image/41.png" alt="" />
    <view class="desc">{{ status == 1 ? '授权成功' : '授权失败' }}</view>
    <view class="btn flex">
      <text @click="tools.navTo('/pages/match/index', 3)">返回首页</text>
      <text v-if="status == 1" @click="tools.navTo('/pagesA/mine/tickets')">查看授权</text>
    </view>
  </view>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { setPower } from '@/service/api/user'
import tools from '@/utils/tools'

let status = ref(null)

const setPowerApi = async (id) => {
  const { code } = await setPower({ id })
  if (code == 1) return (status.value = 1)
  status.value = 0
}

onLoad((option) => {
  setPowerApi(decodeURIComponent(option.scene))
})
</script>

<style lang="scss" scoped>
.page {
  align-items: center;
  justify-content: center;
}
image {
  width: 334rpx;
  height: 192rpx;
}
.desc {
  height: 40rpx;
  font-size: 28rpx;
  line-height: 40rpx;
  color: #000000;
  margin-top: 40rpx;
}
.btn {
  margin-top: 152rpx;
  text {
    width: 248rpx;
    height: 100rpx;
    font-size: 32rpx;
    text-align: center;
    line-height: 100rpx;
    border-radius: 10rpx;
    &:nth-child(1) {
      color: #e6425e;
      background: rgba(249, 249, 249);
    }
    &:nth-child(2) {
      color: #fff;
      margin-left: 80rpx;
      background: #e6425e;
    }
  }
}
</style>
